import { saveMonitorhcDispose } from '@/services/api/api-monitorhc-dispose';
import { DrawerForm, ProFormRadio, ProFormTextArea } from '@ant-design/pro-components';
import { message } from 'antd';

interface AddMonitorDisposeReplyProps {
  data: MonitorhcData.RecordPage;
  onRefurbish: () => void;
}
const AddMonitorDisposeReply: React.FC<AddMonitorDisposeReplyProps> = ({
  data,
  onRefurbish,
}) => {
  return (
    <DrawerForm
      title="处置"
      resize={{
        onResize() {
          console.log('resize!');
        },
        minWidth: 600,
      }}
      trigger={<a>处置</a>}
      autoFocusFirstInput
      drawerProps={{
        destroyOnClose: true,
      }}
      submitTimeout={2000}
      onFinish={async (values) => {
        if (values.scheme == undefined) {
          message.warning('请选择处置方案');
          return false;
        }

        const res = await saveMonitorhcDispose({
          includeRecordId: data.id,
          scheme: values.scheme,
          content: values.content,
        });

        if (res.code === 0) {
          message.success('处置成功');
          onRefurbish();
          return true;
        }
        // 不返回不会关闭弹框
        return false;
      }}
    >
      <ProFormRadio.Group
        label="处置类型"
        name="scheme"
        required={true}
        options={[
          {
            label: '不需要处理',
            value: 1,
          },
          {
            label: '下架不再发稿',
            value: 2,
          },
          {
            label: '下架修改重新发稿',
            value: 3,
          },
          {
            label: '其他方案',
            value: 4,
          },
        ]}
      />

      <ProFormTextArea name="content" label="处置备注" placeholder="请输入处置备注" />
    </DrawerForm>
  );
};
export default AddMonitorDisposeReply;
